#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5,mod=998244353;
int n,k,jc[N],ms[N],inv[N],ans1,j,i,ans,z;
int main()
{
	freopen("length.in","r",stdin);
	freopen("length.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	cin>>n>>k;
	ms[0]=jc[0]=inv[0]=1;
	for(int i=1;i<n;++i)
		ms[i]=(1ll*ms[i-1]*n)%mod;
	for(int i=1;i<=n;++i)
		jc[i]=(1ll*jc[i-1]*i)%mod;
	inv[n]=1;
	j=mod-2;
	i=jc[n];
	while(j)
	{
		if(j&1==1) inv[n]=(1ll*inv[n]*i)%mod;
		j/=2;
		i=(1ll*i*i)%mod; 
	}
	for(int i=n-1;i>=1;--i)
		inv[i]=(1ll*inv[i+1]*(i+1))%mod;
	for(int i=1;i<=n;++i)
	{
		ans=1;
		j=k;
		z=i;
		while(j)
		{
			if(j&1==1) ans=(1ll*ans*z)%mod;
			j/=2;
			z=(1ll*z*z)%mod; 
		}
		ans1=(1ll*jc[n]*inv[n-i]%mod*inv[i]%mod*ans%mod*ms[n-i]%mod*jc[i-1]%mod+ans1)%mod;
	}
	cout<<ans1;
	return 0;
}
